home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group93c.txt / 000106_icon-group-sender _Wed Dec 1 10:01:23 1993.msg < prev    next >
Internet Message Format  |  1994-02-02  |  27KB

  1. Received: by cheltenham.cs.arizona.edu; Wed, 1 Dec 1993 10:02:19 MST
  2. Date: Wed, 1 Dec 93 10:01:23 MST
  3. From: gmt (Gregg Townsend)
  4. Message-Id: <9312011701.AA00526@owl.cs.arizona.edu>
  5. To: icon-group
  6. Subject: set insertion during generation
  7. Content-Length: 25796
  8. Status: R
  9. Errors-To: icon-group-errors@cs.arizona.edu
  10.  
  11. [ Here are several related messages from the comp.lang.icon newsgroup,
  12.   forwarded to the Icon-group mailing list as one long message. ]
  13.  
  14. ------------------------------------------------------------------------
  15.  
  16. From: norman@flaubert.bellcore.com (Norman Ramsey)
  17. Organization: Bellcore
  18. Date: Tue, 23 Nov 1993 03:50:18 GMT
  19.  
  20. What guarantees does Icon provide if I alter a structured value in the
  21. middle of generating elements of that value?
  22.   s := set()
  23.    ...
  24.   every x := !s do if p(x) then delete(s, x) else insert(s, [x])
  25.  
  26. Is open(mumble, "bp") legitimate, and if so, what are its semantics?
  27. (I want to write, e.g.,  `nntpserver := open("telnet foo 119", "bp")'
  28. and have my Icon program talk to an NNTP server.)
  29.  
  30. Norman
  31. --
  32. Norman Ramsey
  33. norman@bellcore.com
  34.  
  35. ------------------------------------------------------------------------
  36.  
  37. From: nevin@CS.Arizona.EDU (Nevin Liber)
  38. Date: 23 Nov 1993 05:59:38 -0700
  39. Organization: University of Arizona CS Department, Tucson AZ
  40.  
  41. In article <CGxEnw.Lwq@walter.bellcore.com>,
  42. Norman Ramsey <norman@flaubert.bellcore.com> wrote:
  43.  
  44. >What guarantees does Icon provide if I alter a structured value in the
  45. >middle of generating elements of that value?
  46. >  s := set()
  47. >   ...
  48. >  every x := !s do if p(x) then delete(s, x) else insert(s, [x])
  49.  
  50. None, I believe.  What kind if guarantees were you expecting?  You are
  51. generating elements from a collection of unordered (important point
  52. here), unique elments.  Any guarantees that I can think of would force
  53. order on that collection.
  54.  
  55. In reality, if you use ! on the same set twice, you get the elements in
  56. the same order, because from an implementation point of view, it takes
  57. work to create a nonpredictable, random order for things.  But
  58. implementations can change.
  59.  
  60. If you want a guarantee like, say, all elements of the original set
  61. should be generated, you could use a construct like:
  62.  
  63. every x := !copy(s) do ...
  64.  
  65. >Is open(mumble, "bp") legitimate, and if so, what are its semantics?
  66.  
  67. I believe that it is legitimate.  Although its been a while since I
  68. looked the Icon source code, I believe that it just passes the flags
  69. down to C, so it would have the same semantics as opening a pipe under
  70. C.
  71. -- 
  72.     Nevin ":-)" Liber    nevin@cs.arizona.edu    (602) 293-2799
  73.  
  74. ------------------------------------------------------------------------
  75.  
  76. From: Darren New <dnew@thumper.bellcore.com>
  77. Organization: Bellcore
  78. Date: Tue, 23 Nov 1993 14:16:25 GMT
  79.  
  80. > >What guarantees does Icon provide if I alter a structured value in the 
  81. > >middle of generating elements of that value? 
  82. > None, I believe.  What kind if guarantees were you expecting?  
  83. Perhaps the kind of guarantee that the Hermes language offers, which is
  84. that the effect of the iterator is as if the tabler/set/list/whatever
  85. being iterated over is copied before iteration starts (which is, I
  86. think, what the compiler does if there are any modifications to its
  87. contents within the scope of the loop). Nothing to do with the order of
  88. iteration at all. 
  89.  
  90. That is, I think the point is "if I insert an element into a set I'm
  91. iterating over, will it always/never/sometimes show up in the
  92. iteration?" 
  93.  
  94. > In reality, if you use ! on the same set twice, you get the elements in 
  95. > the same order, because from an implementation point of view, it takes 
  96. > work to create a nonpredictable, random order for things.  But 
  97. > implementations can change. 
  98. Actually, there was talk of assuring different orders of iteration
  99. during different runs of a Hermes program, merely to prevent programs
  100. from being accidentally written that depend on the order of iteration.
  101. Now *that* is user-friendly.  :-) 
  102.  
  103. ------------------------------------------------------------------------
  104.  
  105. From: swampler@noao.edu (Steve Wampler)
  106. Organization: National Optical Astronomy Observatories, Tucson AZ
  107. Date: Tue, 23 Nov 1993 15:24:30 GMT
  108.  
  109. In article <CGy7nE.Kz0@walter.bellcore.com>, Darren New <dnew@thumper.bellcore.com> writes:
  110. |> > >What guarantees does Icon provide if I alter a structured value in the 
  111. |> > >middle of generating elements of that value? 
  112. |> > None, I believe.  What kind if guarantees were you expecting?  
  113. |> Perhaps the kind of guarantee that the Hermes language offers, which is
  114. |> that the effect of the iterator is as if the tabler/set/list/whatever
  115. |> being iterated over is copied before iteration starts (which is, I
  116. |> think, what the compiler does if there are any modifications to its
  117. |> contents within the scope of the loop). Nothing to do with the order of
  118. |> iteration at all. 
  119.  
  120. Careful.  Icon doesn't iterate over objects, but across result sequences.
  121. (I.e. every just drives goal-directed evaluation(GDE) through all
  122. results of an expression.)  I don't think you'd want to use a language
  123. that copied all data objects in expressions that are involved in GDE!
  124.  
  125. consider:
  126.  
  127. every a <- !s1 || !s2 || !s3 do {...}
  128.  
  129. how many copies of s3 would have to be produced during evaluation of this?
  130. (And I would imagine the evaluation mechanism would have to be pretty
  131. complicated to manage the above...)
  132.  
  133. Finally, what about the cases where you're not driving GDE with an every,
  134. but there is still GDE taking place?  e.g.:
  135.  
  136. match(!s1 || !s2, !s3) 
  137.  
  138. again, I think there'd be a pretty hefty performance hit to provide
  139. any sort of 'guarantee'.  (Not to mention the complexity if !s3 is
  140. replaced with f(s3).)
  141.  
  142. ------------------------------------------------------------------------
  143.  
  144. From: dnew@thumper.bellcore.com (Darren New)
  145. Date: 23 Nov 93 17:02:00 GMT
  146. Organization: Bellcore
  147.  
  148. > Careful.  Icon doesn't iterate over objects, but across result sequences. 
  149.  
  150. This is a good point. But Hermes iterates over "tables"  (i.e.,
  151. relational database-like tables) so that doesn't come up here. It also
  152. only copies when such copying is needed to ensure the semantics. 
  153.  
  154. > (I.e. every just drives goal-directed evaluation(GDE) through all 
  155. results of an expression.)  
  156.  
  157. This kind of begs the question, tho. What's the behavior of ! in this
  158. case, then? If "every" is just the GDE control structure, then "!"
  159. should have some defined semantics (or explicitly undefined semantics,
  160. yuck) as to what it does if the argument is changed while suspended. 
  161.  
  162. I wasn't arguing for copying, BTW. That was just an example of
  163. semantics. Another example might be to give a function body (including
  164. suspends, returns, and fails) that is the equivalent of each built in
  165. operator (like !). Something like the listing of "tab()" on page 178 of
  166. the second ed of The Icon Programming Language. 
  167.  
  168. > again, I think there'd be a pretty hefty performance hit to provide 
  169. > any sort of 'guarantee'.  (Not to mention the complexity if !s3 is 
  170. > replaced with f(s3).) 
  171.  
  172. Well, I would rather have a performance hit than have a program that
  173. works fine with one version of Icon and coredumps with another. That
  174. sounds too much like C to me.  ;-) 
  175. If I need to copy it in some circumstances (e.g., I'm adding a new
  176. element to a set for every element already in the set) then I need to
  177. know whether I'm going to see all the new elements or not. If I *might*
  178. see the new elements, that's a guarantee too, in that I'm guaranteed to
  179. have to copy the set myself before starting. But leaving it undefined
  180. tends to cause people to "try and see," which works poorly when you
  181. upgrade the interpreter, or use the compiler instead, or port it from
  182. UNIX to MS-DOS, or whatever.       -- Darren 
  183.  
  184. ------------------------------------------------------------------------
  185.  
  186. From: espie@basilic.ens.fr (Marc Espie)
  187. Organization: LIENS, ENS, 45 rue d'Ulm, Paris (France)
  188. Date: Wed, 24 Nov 93 09:45:13 GMT
  189.  
  190. In article <CGyFBE.4vz@walter.bellcore.com> dnew@thumper.bellcore.com (Darren New) writes:
  191. [...]
  192. >
  193. >I wasn't arguing for copying, BTW. That was just an example of
  194. >semantics. Another example might be to give a function body (including
  195. >suspends, returns, and fails) that is the equivalent of each built in
  196. >operator (like !). Something like the listing of "tab()" on page 178 of
  197. >the second ed of The Icon Programming Language. 
  198. >
  199. >> again, I think there'd be a pretty hefty performance hit to provide 
  200. >> any sort of 'guarantee'.  (Not to mention the complexity if !s3 is 
  201. >> replaced with f(s3).) 
  202. >
  203. >Well, I would rather have a performance hit than have a program that
  204. >works fine with one version of Icon and coredumps with another. That
  205. >sounds too much like C to me.  ;-) 
  206. >If I need to copy it in some circumstances (e.g., I'm adding a new
  207. >element to a set for every element already in the set) then I need to
  208. >know whether I'm going to see all the new elements or not. If I *might*
  209. >see the new elements, that's a guarantee too, in that I'm guaranteed to
  210. >have to copy the set myself before starting. But leaving it undefined
  211. >tends to cause people to "try and see," which works poorly when you
  212. >upgrade the interpreter, or use the compiler instead, or port it from
  213. >UNIX to MS-DOS, or whatever.       -- Darren 
  214. Ok, how about that for a semantics: if you try and add an element to the
  215. set while you're scanning it and resume the scan, you get a runtime error.
  216.  
  217. Sounds pretty reasonable to me.
  218. - cheap to implement.
  219. - well-defined semantics.
  220.  
  221. What are you doing adding elements to a set while you're scanning it anyway ?
  222. That's unelegant, relies on side-effects, and not a good idea anyway.
  223. One very good thing about Icon is: keep it simple. Understandable semantics,
  224. orthogonal language, everything set up carefully... 
  225.  
  226. Anyway, considering the overall structure of the language, except IF you're
  227. a very, very naughty programmer, such a hack as adding an element in the
  228. middle of a scan would be fixed in a jiffy.
  229.  
  230.  
  231. -- 
  232. [nosave]
  233.      Marc Espie (Marc.Espie@ens.fr)
  234. ``I'm gonna dance the dream
  235. And make the dream come true''
  236.  
  237. ------------------------------------------------------------------------
  238.  
  239. From: dnew@thumper.bellcore.com (Darren New)
  240. Date: 24 Nov 93 14:16:36 GMT
  241. Organization: Bellcore
  242.  
  243. > Ok, how about that for a semantics: if you try and add an element to the 
  244. > set while you're scanning it and resume the scan, you get a runtime error. 
  245. Sounds reasonable to me.  Better than having it work on some platforms
  246. and fail on others. 
  247.  
  248. > What are you doing adding elements to a set while you're scanning it anyway ? 
  249. > That's unelegant, relies on side-effects, and not a good idea anyway. 
  250. Oh baloney. Take a set of employee's names. Iterate thru it and add to
  251. it the set of spouses of those names. You now have the set of people
  252. covered by the insurance.  There's lots of reasons why you'd want to do
  253. something like that.  I don't see why it's more elegant to use two sets
  254. (if the semantics said you needn't, which they don't in Icon), and I
  255. don't see why relying on side-effects is a problem in a language like
  256. Icon. 
  257.  
  258. > Understandable semantics, 
  259. Debatable, as this discussion shows... 
  260. > orthogonal language, everything set up carefully... 
  261. Yes. Icon *is* very nice. No question there.  Most of my code works the
  262. first time it runs to completion without a run-time error. And most of
  263. the run-time errors are pretty trivial to fix, on the order of syntax
  264. errors. 
  265.  
  266. > such a hack as adding an element in the middle of a scan would be fixed
  267. > in a jiffy. 
  268. Sure, if the semantics were "don't do this." 
  269. It's a shame there aren't more languages with formal semantics of some form. 
  270.  
  271.  
  272. -- 
  273. 445 South St/MRE 2E-279/Morristown NJ 07960 USA/(201)829-4833 
  274. Delivery of Electronic Multimedia over Networks (DEMON) 
  275. Also, formal description techniques, programming languages. 
  276. ``Your fault: Core dumped.''                EFF#846 
  277. ``Sometimes, you just have to bite the silver bullet.'' 
  278.  
  279. ------------------------------------------------------------------------
  280.  
  281. From: nevin@CS.Arizona.EDU (Nevin Liber)
  282. Date: 24 Nov 1993 12:22:39 -0700
  283. Organization: University of Arizona CS Department, Tucson AZ
  284.  
  285. In article <CGy7nE.Kz0@walter.bellcore.com>,
  286. Darren New  <dnew@thumper.bellcore.com> wrote:
  287. >Perhaps the kind of guarantee that the Hermes language offers, which is
  288. >that the effect of the iterator is as if the tabler/set/list/whatever
  289. >being iterated over is copied before iteration starts (which is, I
  290. >think, what the compiler does if there are any modifications to its
  291. >contents within the scope of the loop).
  292.  
  293. If you need that guarantee, it is fairly easy to implement (generate
  294. over copy(s) instead of s).
  295.  
  296. Personally, just about all my code doesn't modify a data structure if
  297. it is being generated upon via !.
  298.  
  299. >That is, I think the point is "if I insert an element into a set I'm
  300. >iterating over, will it always/never/sometimes show up in the
  301. >iteration?" 
  302.  
  303. Sometimes (it "generates" them in the order it is stored in the
  304. internal hash table, I believe.)
  305.  
  306. >Actually, there was talk of assuring different orders of iteration
  307. >during different runs of a Hermes program, merely to prevent programs
  308. >from being accidentally written that depend on the order of iteration.
  309. >Now *that* is user-friendly.  :-) 
  310.  
  311. For development, I totally agree.  However, once I am done
  312. writing/debugging/modifying the code, I don't want to pay this
  313. performance penalty.  I'd rather have the computer spending its cycles
  314. doing useful work for me.
  315. -- 
  316.     Nevin ":-)" Liber    nevin@cs.arizona.edu    (602) 293-2799
  317.  
  318. ------------------------------------------------------------------------
  319.  
  320. From: nevin@CS.Arizona.EDU (Nevin Liber)
  321. Date: 24 Nov 1993 12:40:13 -0700
  322. Organization: University of Arizona CS Department, Tucson AZ
  323.  
  324. In article <CGyFBE.4vz@walter.bellcore.com>,
  325. Darren New <dnew@thumper.bellcore.com> wrote:
  326.  
  327. >case, then? If "every" is just the GDE control structure, then "!"
  328. >should have some defined semantics (or explicitly undefined semantics,
  329. >yuck) as to what it does if the argument is changed while suspended. 
  330.  
  331. I disagree with the "yuck" part of your statement.  Typically, if you
  332. are pressed to define the semantics for something uncommon (like
  333. modifying a structure you are iterating over), you pretty much lock
  334. yourself into only one possible implementation.  Also, from a code
  335. maintenance point of view, this makes the language harder to master
  336. because there are more of these special cases to memorize.
  337.  
  338. Here is an example:  in the map(sString, sSource, sDestination) function,
  339. is disambiguation of duplicate characters in sSource done left-to-right
  340. or right-to-left?  Wouldn't it have been simpler to just say this
  341. results in undefined behavior and should be avoided, than to pin it down
  342. based on the implementation?  As a matter of fact, if there was a
  343. "debug" version of Icon, it could actually check for these violations,
  344. while in the "production" version, you don't get the performance hit.
  345.  
  346. >Well, I would rather have a performance hit than have a program that
  347. >works fine with one version of Icon and coredumps with another.
  348.  
  349. While I'm developing something, I totally agree with you.  But I don't
  350. want my production system to suffer because of these checks.
  351.  
  352. >If I need to copy it in some circumstances (e.g., I'm adding a new
  353. >element to a set for every element already in the set) then I need to
  354. >know whether I'm going to see all the new elements or not.
  355.  
  356. I don't see how you can ask for this, without wanting an implicit order
  357. on the set (eg: by time) or copy first semantics (which is still
  358. ordering by time; it just says that you don't want any elements
  359. produced after the set was instanciated by !).
  360.  
  361. >If I *might*
  362. >see the new elements, that's a guarantee too, in that I'm guaranteed to
  363. >have to copy the set myself before starting.
  364.  
  365. That's all I would count on.  It's the "safest" assumption.  Anything
  366. else would make me look it up every time I saw it.
  367.  
  368. >But leaving it undefined
  369. >tends to cause people to "try and see," which works poorly when you
  370. >upgrade the interpreter, or use the compiler instead, or port it from
  371. >UNIX to MS-DOS, or whatever.
  372.  
  373. Agreed.  Actually, a good reference on this kind of stuff is "Writing
  374. Solid Code", by Steve MaGuire, published by Microsoft Press.
  375. -- 
  376.     Nevin ":-)" Liber    nevin@cs.arizona.edu    (602) 293-2799
  377.  
  378. ------------------------------------------------------------------------
  379.  
  380. From: nevin@CS.Arizona.EDU (Nevin Liber)
  381. Date: 24 Nov 1993 12:49:04 -0700
  382. Organization: University of Arizona CS Department, Tucson AZ
  383.  
  384. In article <1993Nov24.094513.20348@ens.fr>,
  385. Marc Espie <espie@basilic.ens.fr> wrote:
  386.  
  387. >Ok, how about that for a semantics: if you try and add an element to the
  388. >set while you're scanning it and resume the scan, you get a runtime error.
  389.  
  390. >Sounds pretty reasonable to me.
  391. >- cheap to implement.
  392. >- well-defined semantics.
  393.  
  394. I'm not convinced that it is all that cheap to implement (then again,
  395. I'm really sleepy right now, so take what I say with a grain of salt
  396. :-)).  Consider the following code fragment:
  397.  
  398. every x := !S do {
  399.     ...
  400.     insert(S, foo)
  401.     ...
  402.     every y := !S do {
  403.         ...
  404.     }
  405. }
  406.  
  407. How do you keep track of whether you are resuming the first one or the
  408. second one (or the nth one, if being called recursively)?  I think that
  409. this will get messy.
  410.  
  411. I also believe that run-time errors are a last-ditch bailing mechanism,
  412. when you can't think of anything reasonable to do.  Then again, maybe
  413. that does apply here.
  414.  
  415. >What are you doing adding elements to a set while you're scanning it anyway ?
  416. >That's unelegant, relies on side-effects, and not a good idea anyway.
  417.  
  418. I agree with you 100% here, and never do it myself.
  419. -- 
  420.     Nevin ":-)" Liber    nevin@cs.arizona.edu    (602) 293-2799
  421.  
  422. ------------------------------------------------------------------------
  423.  
  424. From: nevin@CS.Arizona.EDU (Nevin Liber)
  425. Date: 24 Nov 1993 12:55:44 -0700
  426. Organization: University of Arizona CS Department, Tucson AZ
  427.  
  428. In article <CH02Bp.Lz5@walter.bellcore.com>,
  429. Darren New <dnew@thumper.bellcore.com> wrote:
  430. >> What are you doing adding elements to a set while you're scanning it anyway ? 
  431. >> That's unelegant, relies on side-effects, and not a good idea anyway. 
  432. >Oh baloney. Take a set of employee's names. Iterate thru it and add to
  433. >it the set of spouses of those names. You now have the set of people
  434. >covered by the insurance.  There's lots of reasons why you'd want to do
  435. >something like that.  I don't see why it's more elegant to use two sets
  436. >(if the semantics said you needn't, which they don't in Icon), and I
  437. >don't see why relying on side-effects is a problem in a language like
  438. >Icon. 
  439.  
  440. Well, there is nothing wrong with doing that from a language point of
  441. view.  However, I would claim that you are breaking the abstraction of
  442. what that set stands for.  First it is a set of employee names; now it
  443. is a set of people covered by insurance.  If I want to convert one of
  444. these to another, I use two different variables, because I am naming
  445. two different types of objects.  Unless you are really, really pressed
  446. for space efficiency, I believe that it is much clearer to use two
  447. different sets for this.
  448. -- 
  449.     Nevin ":-)" Liber    nevin@cs.arizona.edu    (602) 293-2799
  450.  
  451. ------------------------------------------------------------------------
  452.  
  453. From: norman@flaubert.bellcore.com (Norman Ramsey)
  454. Organization: Bellcore
  455. Date: Wed, 24 Nov 1993 21:06:44 GMT
  456.  
  457. >>What guarantees does Icon provide if I alter a structured value in the
  458. >>middle of generating elements of that value?
  459. >>  s := set()
  460. >>   ...
  461. >>  every x := !s do if p(x) then delete(s, x) else insert(s, [x])
  462. >
  463. >None, I believe.  What kind if guarantees were you expecting?  
  464.  
  465. Here are some possible guarantees:
  466.   - every element that was in s before `every' started executing will
  467.     be generated
  468.   - inserted elements might be generated, might not
  469.   - inserted elements won't be generated
  470.   - inserted elements will be generated
  471. Here is what I fear:
  472.   - the behavior of the construct is undefined
  473.  
  474. Norman
  475.  
  476. ------------------------------------------------------------------------
  477.  
  478. From: norman@flaubert.bellcore.com (Norman Ramsey)
  479. Organization: Bellcore
  480. Date: Wed, 24 Nov 1993 21:10:31 GMT
  481.  
  482. >What are you doing adding elements to a set while you're scanning it anyway ?
  483. >That's unelegant, relies on side-effects, and not a good idea anyway.
  484.  
  485. Nonsense.  
  486.   every x := !s & type(x) == "field" & insert(s, !extensions[x])
  487. makes sure s is closed under the ``extensions'' relation.  (In this
  488. case I needn't worry about generating elements of extensions[x]
  489. because they never have type "field".)
  490.  
  491. ------------------------------------------------------------------------
  492.  
  493. From: Darren New <dnew@thumper.bellcore.com>
  494. Organization: Bellcore
  495. Date: Wed, 24 Nov 1993 22:42:00 GMT
  496.  
  497. > First it is a set of employee names; now it 
  498. is a set of people covered by insurance.  
  499.  
  500. Nope. I just want the people covered by insurance.  However, all I have
  501. access to is two different tables: employees, and their spouses.  There
  502. has to be an intermediate expression where only some of the people are
  503. in the set. If nothing else, you can't generate a set of employees
  504. because you have to insert them in the set one at a time, see. So at
  505. *some* point the set will be "the set of employees I've gotten around to
  506. inserting so far."  Maybe if we were using SQL I could do it with one
  507. loop.  But that isn't always possible in Icon. 
  508.  
  509. ------------------------------------------------------------------------
  510.  
  511. From: gmt@CS.Arizona.EDU (Gregg Townsend)
  512. Date: 24 Nov 1993 17:37:51 -0700
  513. Organization: University of Arizona CS Department, Tucson AZ
  514.  
  515. Fear not.  It is safe to insert and delete items of a set while the set is
  516. being generated. Items that are neither inserted nor deleted are generated
  517. exactly once.  Norman Ramsey and Darren New each gave an example of why
  518. this is useful.
  519.  
  520. An inserted item may or may not be generated once, depending on enough
  521. different factors that you might as well consider it random.
  522.  
  523.     Gregg Townsend / Icon Project / Computer Science Dept / Univ of Arizona
  524.     +1 602 621 4325     gmt@cs.arizona.edu     110 57 16 W / 32 13 45 N / +758m
  525.  
  526. ------------------------------------------------------------------------
  527.  
  528. From: nevin@CS.Arizona.EDU (Nevin Liber)
  529. Date: 28 Nov 1993 08:14:38 -0700
  530. Organization: University of Arizona CS Department, Tucson AZ
  531.  
  532. In article <CH0LB8.ECq@walter.bellcore.com>,
  533. Norman Ramsey <norman@flaubert.bellcore.com> wrote:
  534. > Here are some possible guarantees:
  535. > ...
  536. >  - inserted elements might be generated, might not
  537.  
  538. >Here is what I fear:
  539. >  - the behavior of the construct is undefined
  540.  
  541. I'm not sure why you accept the first statement as a useful guarantee,
  542. and fear the second one.  From a practical point of view, I can find no
  543. difference between statement one and statement two, as far as inserted
  544. elements are concerned.  Is there any possible situation where you can
  545. do something if statement one is guaranteed, vs it being undefined?
  546. -- 
  547.     Nevin ":-)" Liber    nevin@cs.arizona.edu    (602) 293-2799
  548.  
  549. ------------------------------------------------------------------------
  550.  
  551. From: norman@flaubert.bellcore.com (Norman Ramsey)
  552. Date: 29 Nov 93 02:02:11 GMT
  553. Organization: Bellcore, Morristown NJ
  554.  
  555. In article <2daf8u$jnl@caslon.cs.arizona.edu>,
  556. Nevin Liber <nevin@CS.Arizona.EDU> wrote:
  557. >>  - inserted elements might be generated, might not
  558. >>  - the behavior of the construct is undefined
  559. >
  560. >I'm not sure why you accept the first statement as a useful guarantee,
  561. >and fear the second one.  From a practical point of view, I can find no
  562. >difference between statement one and statement two
  563.  
  564. In language definition, `behavior undefined' means `anything can
  565. happen', including a runtime error that brings down the program.  
  566. There are lots of examples in the C standard.
  567.  
  568. Norman
  569.  
  570. ------------------------------------------------------------------------
  571.  
  572. From: nevin@CS.Arizona.EDU (Nevin Liber)
  573. Date: 29 Nov 1993 07:45:59 -0700
  574. Organization: University of Arizona CS Department, Tucson AZ
  575.  
  576. In article <CH8Dno.9IM@walter.bellcore.com>,
  577. Norman Ramsey <norman@flaubert.bellcore.com> wrote:
  578. >In article <2daf8u$jnl@caslon.cs.arizona.edu>,
  579. >Nevin Liber <nevin@CS.Arizona.EDU> wrote:
  580. >>>  - inserted elements might be generated, might not
  581. >>>  - the behavior of the construct is undefined
  582.  
  583. >In language definition, `behavior undefined' means `anything can
  584. >happen', including a runtime error that brings down the program.  
  585. >There are lots of examples in the C standard.
  586.  
  587. But I don't find the statement "Anything can happen except a runtime
  588. error, theomonuclear war, etc." any more useful than saying "Anything 
  589. can happen" (undefined).
  590.  
  591. If you believe otherwise, please post a code fragment where you can do
  592. something useful with "inserted elements might or might not be
  593. generated" as the semantics vs "undefined" as the semantics.
  594.  
  595. Sentences with the phrases "might", "might not", "may", "may not",
  596. "might or might not", "may or may not" are pretty much unnecessary in a
  597. technical definition.  They are useful only for pointing something out the
  598. reader might have overlooked.  You can exchange any one of the above
  599. phrases with any other one of the above phrases or take the whole
  600. sentence out without changing the meaning of the definition.
  601. -- 
  602.     Nevin ":-)" Liber    nevin@cs.arizona.edu    (602) 293-2799
  603.  
  604. ------------------------------------------------------------------------
  605.  
  606. From: norman@flaubert.bellcore.com (Norman Ramsey)
  607. Organization: Bellcore, Morristown NJ
  608. Date: Mon, 29 Nov 1993 23:04:11 GMT
  609.  
  610. >But I don't find the statement "Anything can happen except a runtime
  611. >error, theomonuclear war, etc." any more useful than saying "Anything 
  612. >can happen" (undefined).
  613. >
  614. >If you believe otherwise, please post a code fragment where you can do
  615. >something useful with "inserted elements might or might not be
  616. >generated" as the semantics vs "undefined" as the semantics.
  617.  
  618. Under the invariant that no value in t has type integer,
  619.  
  620.   every type(x := !s) == "integer" do insert(s, t[x])
  621.  
  622. is safe and well defined in the maybe, maybe not semantics.  In the
  623. undefined semantics it's unsafe and I'm forced to write
  624.  
  625.   ss := set()
  626.   every type(x := !s) == "integer" do insert(ss, t[x])
  627.   every insert(s, !ss)
  628.  
  629.